package cn.exrick.xboot.base.serviceimpl

import cn.exrick.xboot.base.entity.EnterpriseUserStatus
import cn.exrick.xboot.base.mapper.EnterpriseUserStatusMapper
import cn.exrick.xboot.base.service.IEnterpriseUserStatusService
import cn.exrick.xboot.core.common.utils.ResultUtil
import cn.exrick.xboot.core.common.utils.ToolUtil
import cn.exrick.xboot.core.common.vo.Result
import com.baomidou.mybatisplus.extension.kotlin.KtQueryWrapper
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
import lombok.extern.slf4j.Slf4j
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional

/**
 * 企业状态接口实现
 * @author Fei
 */
@Slf4j
@Service
@Transactional
open class IEnterpriseUserStatusServiceImpl : ServiceImpl<EnterpriseUserStatusMapper?, EnterpriseUserStatus?>(), IEnterpriseUserStatusService {

    override fun updateEnterpriseUserStatus(enterpriseUserStatus: EnterpriseUserStatus): Result<Any?>? {

        return try {

            getOne(KtQueryWrapper(EnterpriseUserStatus::class.java).eq(EnterpriseUserStatus::enterpriseUserId, enterpriseUserStatus.enterpriseUserId))?.run {

                managementForms = enterpriseUserStatus.managementForms
                updateById(this)
            }

            ResultUtil.success("操作成功")
        }catch (e : Exception) {

            ResultUtil.error(e.message)
        }
    }
}